﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using RBAC.DAL.Entities;

namespace RBAC.DAL.Mappers
{
    public class PermissionMap : ClassMap<Permission>
    {
        public PermissionMap()
        {
            Id(x => x.Id);

            Map(x => x.PermissionName).Not.Nullable().Length(255).UniqueKey("UQ_Permission_PermissionName");

            Map(x => x.Description).Not.Nullable().Length(255);

            //Map(x => x.CreateDate).Not.Nullable();

            References(x => x.Role).Cascade.All();

            References(x => x.Function).Cascade.All();

            //Map(x => x.PermissionStatus).Not.Nullable();

            References(x => x.RoleLookup).Cascade.All();

            // BaseEntity
            //References(x => x.CreateBy).Cascade.All();
            Map(x => x.CreateById).Nullable();

            Map(x => x.CreateDate).Not.Nullable();

            Map(x => x.IsActive).Not.Nullable();

            Map(x => x.ProjectId).Not.Nullable().UniqueKey("UQ_Permission_PermissionName");
        }

    }
}